home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / Gui4Cli / Tools / ViewFile.g < prev   
Encoding:
Gui4CLI script  |  1980-01-03  |  6.4 KB  |  252 lines

  1. G4C  
  2.  
  3. ; This file contains a routine, to read the file selected according
  4. ; to it's type. You can add type checks here, to your heart's content.
  5.  
  6. ; The following things MUST be done before it's called :
  7.  
  8. ; 1. Load the DEF.player variables by first gui-loading the 
  9. ;    guis:tools/prefs/players file.
  10.  
  11. ; 2. Set GLOBAL variable FILENAME to the name of file to be viewed
  12.  
  13. ; 3. (Optional) Set GLOBAL variable RUNMODE.
  14. ;    The file chosen will (in most cases) be executed as follows :
  15. ;    CLI '$RUNMODE $DEF.player $FILENAME'
  16. ;    - so if RUNMODE = 'run >nil:'
  17. ;    then the file will be run - otherwise, if not set, the file will
  18. ;    be CLI'ied i.e. executed synchronously and Gui4Cli will wait until
  19. ;    finished. This is helpfull if you want to show many pictures for
  20. ;    example, where you don't want to show them all at once but 1 by 1.
  21.  
  22. ;    The RUNMODE variable will be reset to '' upon exit.
  23.  
  24.  
  25. varpath '*/cli.gc'                            ; use the global variable path
  26.  
  27. xOnQuit
  28. guiquit ViewMore
  29.  
  30. ; This is the start of the one and only routine in this gui
  31.  
  32. xRoutine ViewFile
  33. runmode = $*RUNMODE                     ; store runmode
  34. *RUNMODE = ''                           ; and null the variable
  35. if $FILENAME < "  "            ; FILENAME variable was not set..
  36.    return
  37. endif
  38. extract FILENAME file rtn.temp          ; see if it's a module
  39. cutvar  rtn.temp copy char 4 rtn.mod
  40. delvar  rtn.temp
  41. if $rtn.mod == mod.
  42.    run '$DEF.MOD $FILENAME'
  43.    delvar rtn.mod
  44.    return
  45. endif
  46.  
  47. extract FILENAME ext rtn.ext
  48. docase $rtn.ext
  49. case   = ".info"
  50.        copy $FILENAME ram:t        ; load gui which will show an icon
  51.        ifexists file ram:t/GCXX.info    ; named ram:t/GCXX.info
  52.             delete ram:t/GCXX.info
  53.        endif
  54.        extract FILENAME FILE rtn_info2
  55.        joinfile ram:t $rtn_info2 rtn_info
  56.        rename $rtn_info ram:t/GCXX.info
  57.        guiload guis:tools/icon.gc
  58.        guiopen icon.gc
  59.        guiscreen icon.gc front
  60.        return
  61.        break
  62. case   = ".gif"
  63.        CLI '$runmode $DEF.GIF $FILENAME'
  64.        return
  65.        break
  66. case   = ".ppm"
  67.        CLI 'run >NIL: ppm2aga $FILENAME T:temp'
  68.        WAIT FILE T:Temp 1000
  69.        CLI '$runmode $DEF.ILBM T:temp'
  70.        RUN 'delete T:temp'
  71.        return
  72.        break
  73. case   = ".tga"
  74. case   = ".pgm"
  75. case   = ".png"
  76. case   = ".font"
  77.        CLI '$runmode $DEF.MULTIVIEW $FILENAME'
  78.        return
  79.        break
  80. case   = ".S3M"
  81. case   = ".mod"
  82. case   = ".XM"
  83.        CLI '$runmode $DEF.MOD $FILENAME'
  84.        return
  85.        break
  86. endcase
  87.  
  88. ; We reached here so we have to check the type of file using the
  89. ; header comparisson. To do this faster than with H=, we would use:
  90. ; readvar $FILENAME 0 100 header
  91. ; but it's not ready yet...
  92.  
  93. docase $FILENAME
  94. case   H= "ã"                ; icon probably
  95.        copy $FILENAME ram:t        ; load gui which will show an icon
  96.        ifexists file ram:t/GCXX.info    ; named ram:t/GCXX.info
  97.             delete ram:t/GCXX.info
  98.        endif
  99.        extract FILENAME FILE rtn_info2
  100.        joinfile ram:t $rtn_info2 rtn_info
  101.        rename $rtn_info ram:t/GCXX.info
  102.        guiload guis:tools/icon.gc
  103.        guiopen icon.gc
  104.        guiscreen icon.gc front
  105.        return
  106.        break
  107. case   H= "FORM????ILBM"        ; ILBM
  108.        CLI '$runmode $DEF.ILBM $FILENAME'
  109.        return
  110.        break
  111. case   H= "FORM????ANIM"        ; Animation
  112.        CLI '$runmode $DEF.ANIM $FILENAME'
  113.        return
  114.        break
  115. case   H= "GIF"                ; GIF
  116.        CLI '$runmode $DEF.GIF $FILENAME'
  117.        return
  118.        break
  119. case   H= "??????JFIF"            ; JPEG
  120. case   H= "ÿØÿÄ"            ; JPEG
  121.        CLI '$runmode $DEF.JPG $FILENAME'
  122.        return
  123.        break
  124. case   H= "?PNG"            ; PNG
  125. case   H= "P5"                ; PGM
  126.        CLI '$runmode $DEF.MULTIVIEW $FILENAME'
  127.        return
  128.        break
  129. case   H= "P6"                ; PPM - don't ask..
  130.        CLI 'ppm2aga $FILENAME T:temp'
  131.        WAIT FILE T:Temp 1000
  132.        CLI '$runmode $DEF.MULTIVIEW T:temp'
  133.        RUN 'delete T:temp'
  134.        return
  135.        break
  136. case   H= "MMD"                    ; MED
  137. case   H= "Extended Module:"       ; XM
  138. case   H= "????????????????????????????????????????????SCRM"   ; S3M Scream Tracker 3
  139. case   H= "?????????????????????????????????????????????@"     ; I forget
  140.        CLI '$runmode $DEF.MOD $FILENAME'
  141.        return
  142.        break
  143. case   H= "FORM????8SVX"        ; 8svx Sound sample
  144.        CLI '$runmode $DEF.8SVX $FILENAME'
  145.        return
  146.        break
  147. case   H= "PP"                ; PowerPacked file
  148.        CLI '$runmode $DEF.PP $FILENAME'
  149.        return
  150.        break
  151. case   H= G4C                ; Yes.. you guessed it.
  152.        GuiLoad $FILENAME
  153.        return
  154.        break
  155. case   H= "??-lh"            ; LhA - all these are CLI'ied
  156.        cli 'Lha x $FILENAME ram:'
  157.        return
  158.        break
  159. case   H= "ZOO ?.??"            ; zoo
  160.        cli 'Zoo <* x// $FILENAME'
  161.        return
  162.        break
  163. ;case   H= ^Z                ; pkax
  164. ;       cli 'pkax -x $FILENAME'
  165. ;       return
  166. ;       break
  167. case   H= "PK"                ; unzip
  168.        cli 'unzip $FILENAME -d ram:'
  169.        return
  170.        break
  171. case   H= "@"                 ; Amigaguide (probably)
  172.        CLI '$runmode $DEF.GUIDE $FILENAME'
  173.        return
  174.        break
  175. case   H= "%%%ó%"            ; A program ? - Use cli.gc to run it.
  176.        GuiLoad guis:tools/cli.gc
  177.        setvar cl_Main '$FILENAME'
  178.        GuiOpen cli.gc
  179.        GuiScreen cli.gc front
  180.        update  cli.gc 10 2        ; set it to RUN
  181.        setgad cli.gc 1 ON
  182.        return
  183.        break
  184. case   H= "######"                      ; a text file (probably)
  185.        GuiLoad    guis:tools/read.gc
  186.        guiopen    read.gc
  187.        GuiWindow  read.gc FRONT
  188.        GuiScreen  read.gc FRONT
  189.        return
  190.        break
  191. endcase
  192.  
  193. ; If we got this far, let user decide what to do
  194. guiopen ViewMore
  195.  
  196.  
  197. ; ######################################################################
  198.  
  199. NEWFILE ViewMore       ; gui to decide what to do with unresolved files
  200.  
  201. WinBig 0 0 80 75 ""
  202. WinType 01001000
  203. winonmouse 40 10 
  204. varpath ViewFile.g/*/cli.gc
  205.  
  206. xOnRMB 
  207. guiclose ViewMore
  208.  
  209. xOnInactive
  210. guiclose ViewMore
  211.  
  212. xOnFail
  213. ezreq "Error during operation" OK ""
  214.  
  215. ;---------------> the Buttons
  216.  
  217. xbutton 0 0 0 15 MView
  218. guiclose ViewMore
  219. CLI '$runmode $DEF.MULTIVIEW $FILENAME'
  220.  
  221. xbutton 0 15 0 15 List
  222. GuiLoad    guis:tools/read.gc
  223. guiopen    read.gc        
  224. GuiWindow  read.gc FRONT    
  225. GuiScreen  read.gc FRONT    
  226. return
  227. break
  228.  
  229. xbutton 0 30 0 15 Run
  230. guiclose ViewMore
  231. run '$FILENAME'
  232.  
  233. xbutton 0 45 0 15 With..
  234. guiclose ViewMore
  235. prog = ''
  236. ReqFile  -1 -1 300 220 'Run file with..' LOAD prog c:
  237. if $prog > ''
  238.    run '$prog $FILENAME'
  239. endif
  240. delvar prog
  241.  
  242. xbutton 0 60 0 15 'CliGui'
  243. guiclose ViewMore
  244. setvar cl_Main '$FILENAME '
  245. GuiLoad guis:tools/cli.gc
  246. GuiOpen cli.gc
  247. GuiScreen cli.gc front
  248. update  cli.gc 10 1        ; set it to CLI
  249. setgad cli.gc 1 ON
  250.  
  251.  
  252.